package com.jiaoyou.baojian.entity.response;

import com.google.gson.Gson;
import com.jiaoyou.baojian.activity.BaseActivity;
import com.jiaoyou.baojian.entity.Card;
import com.jiaoyou.baojian.entity.Contribution;
import com.jiaoyou.baojian.entity.GiftEntity;
import com.jiaoyou.baojian.entity.RoomEntity;
import com.jiaoyou.baojian.entity.UserDetail;
import com.jiaoyou.baojian.entity.UserEntity;
import com.jiaoyou.baojian.entity.UserInfo;
import com.jiaoyou.baojian.entity.UserRoles;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;

/**
 * Created by DemonZYM on 17/5/10.
 */

public class LoginResponse implements Serializable {

    public static final String TAG = "LoginResponse";

    public boolean accountNonExpired;
    public boolean accountNonLocked;
    public boolean actress;
    public boolean credentialsNonExpired;
    public boolean enabled;

    //用于百川的im帐号密码
//    public String imUserId;
//    public String imPassword;

    public UserEntity user;
    public UserInfo userInfo;
    public List<UserRoles> userRoles;
    public String username;

    /*****userdetail data*****/
    public boolean applyingActress;
    public Card card;   //当前用户虚拟币账户信息，不是被查看的用户
    public List<Contribution> contributionList;  // 被查看用户的守护榜，如果是主播的话
    public List<UserInfo> contributionUserInfoList;  // 守护榜对应的用户信息
    public int fansCount;// 粉丝数
    public boolean fav; // 当前是否关注了被查看用户
    public int favCount; // 关注用户数
    public boolean freeForCall;  //是否可以通话，是否正忙
    public List<GiftEntity> giftList;// 所有礼物列表
    public HashMap<String, Integer> giftMap;// 收到了多少礼物 { giftId : quantity }
    public RoomEntity room;
    public RoomEntity privateRoom;
    public RoomEntity lastClosedPublicRoom;
    public String signalingKey;   //登录用key

    public void update(BaseActivity activity, UserDetail userDetail){
        actress = userDetail.actress;
        applyingActress = userDetail.applyingActress;
        card = userDetail.card;
        contributionList = userDetail.contributionList;
        contributionUserInfoList = userDetail.contributionUserInfoList;
        fansCount = userDetail.fansCount;
        fav = userDetail.fav;
        favCount = userDetail.favCount;
        freeForCall = userDetail.freeForCall;
        giftList = userDetail.giftList;
        giftMap = userDetail.giftMap;
        room = userDetail.room;
        privateRoom = userDetail.privateRoom;
        lastClosedPublicRoom = userDetail.lastClosedPublicRoom;
        user = userDetail.user;
        userInfo = userDetail.userInfo;
        userRoles = userDetail.userRoles;

        activity.getACache().put(LoginResponse.TAG, new Gson().toJson(this));

        activity.updateLoginResponse();
    }
}
